package com.fayou.cloud.seatastorageservice2002.controller;

import com.fayou.cloud.seatastorageservice2002.entity.StorageTbl;
import com.fayou.cloud.seatastorageservice2002.service.StorageTblService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (StorageTbl)表控制层
 *
 * @author makejava
 * @since 2020-06-03 20:00:03
 */
@RestController
@RequestMapping("storage")
public class StorageTblController {
    /**
     * 服务对象
     */
    @Resource
    private StorageTblService storageTblService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public StorageTbl selectOne(@RequestParam("id") Integer id) {
        return this.storageTblService.queryById(id);
    }


    /**
     * 减库存
     * @param commodityCode 商品代码
     * @param count 数量
     * @return
     */
    @RequestMapping(path = "/deduct")
    public Boolean deduct(String commodityCode, Integer count) {
        storageTblService.deduct(commodityCode, count);
        return true;
    }



}